package edu.zju.gis.dbfg.server.service.impl;

import edu.zju.gis.dbfg.common.base.BaseServiceImpl;
import edu.zju.gis.dbfg.server.mapper.MonitorMapper;
import edu.zju.gis.dbfg.server.model.Monitor;
import edu.zju.gis.dbfg.server.service.MonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanlo yanlong_lee@qq.com
 * @version 1.0 2018/08/01
 */
@Service
public class MonitorServiceImpl extends BaseServiceImpl<MonitorMapper, Monitor, String> implements MonitorService {
    @Autowired
    private MonitorMapper monitorMapper;

    @Override
    public Monitor select(String pk) {
        return monitorMapper.selectByPrimaryKey(pk);
    }

    @Override
    public int insert(Monitor monitor) {
        return monitorMapper.insertSelective(monitor);
    }

    @Override
    public int update(Monitor monitor) {
        return monitorMapper.updateByPrimaryKeySelective(monitor);
    }

    @Override
    public int delete(String s) {
        return monitorMapper.deleteByPrimaryKey(s);
    }

    @Override
    public boolean isExist(String s) {
        return monitorMapper.selectByPrimaryKey(s) != null;
    }

    public List<Monitor> getByPage(int offset, int size) {
        return monitorMapper.selectByPage(offset, size);
    }

    @Override
    public Monitor getByName(String name) {
        return monitorMapper.selectByName(name);
    }

    @Override
    public int updateByName(Monitor monitor) {
        return monitorMapper.updateByName(monitor);
    }
}
